Skip to content

Support enum and array based attributes in codegen#1898

Merged
breedx-splk merged 4 commits into
open-telemetry:mainfrom
bidetofevil:hho/enum-attribute-values
Jul 16, 2026
Merged

Support enum and array based attributes in codegen#1898
breedx-splk merged 4 commits into
open-telemetry:mainfrom
bidetofevil:hho/enum-attribute-values

Conversation

@bidetofevil

Copy link
Copy Markdown
Contributor

Fixed attribute templates to work with enum and array-based attribute values. Add in some codegen to create enums and then changed a few internal semconv to use them.

Copilot AI review requested due to automatic review settings July 15, 2026 06:02
@bidetofevil
bidetofevil requested a review from a team as a code owner July 15, 2026 06:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Kotlin semantic-convention codegen templates to support enum-typed attributes (and prepares support for array-typed attributes), then switches a few Android internal semantic conventions and instrumentations to use the generated enums instead of hard-coded strings.

Changes:

  • Update Kotlin weaver/codegen templates to (a) skip any-typed event attributes, (b) generate AttributeKey constants for array types, and (c) generate enum “Values” types for enum attributes.
  • Update the Android semconv registry to express screen.orientation, start.type, and websocket.message.type as enums.
  • Update instrumentation code to use the generated enum values (e.g., StartTypeValues.COLD.value) instead of string literals.

PR Merge Tier: Tier 3 (build/codegen changes + cross-module behavior wiring)

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
semconv/templates/registry/kotlin/weaver.yaml Adds type mappings for array AttributeKey generation and filters out any-typed event attributes.
semconv/templates/registry/kotlin/kotlin_semconv_template.kt.j2 Generates AttributeKey fields for array types and emits enum value classes for enum attributes.
semconv/templates/registry/kotlin/kotlin_event_template.kt.j2 Adds array-attribute handling via AttributeKey.*ArrayKey(...) when emitting event attributes.
semconv/model/android/registry.yaml Converts several attributes from string to enum definitions with members.
instrumentation/screen-orientation/.../ScreenOrientationDetector.kt Uses generated ScreenOrientationValues instead of hard-coded orientation strings.
instrumentation/okhttp3-websocket/.../WebsocketListenerWrapper.kt Uses generated WebsocketMessageTypeValues instead of hard-coded message type strings.
instrumentation/activity/.../AppStartupTimer.kt Uses generated StartTypeValues.COLD.value instead of "cold".
instrumentation/activity/.../ActivityTracer.kt Uses generated StartTypeValues.{WARM,HOT}.value instead of "warm"/"hot".

Comment thread semconv/templates/registry/kotlin/kotlin_event_template.kt.j2

@LikeTheSalad LikeTheSalad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think it's worth checking the comment from Copilot, but overall LGTM.

@fractalwrench fractalwrench left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@breedx-splk breedx-splk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!!

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@breedx-splk
breedx-splk enabled auto-merge (squash) July 16, 2026 20:05
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.33%. Comparing base (6853aa3) to head (6b24f1b).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...ion/screenorientation/ScreenOrientationDetector.kt 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1898      +/-   ##
==========================================
+ Coverage   64.89%   65.33%   +0.43%     
==========================================
  Files         168      169       +1     
  Lines        3723     3871     +148     
  Branches      390      420      +30     
==========================================
+ Hits         2416     2529     +113     
- Misses       1194     1211      +17     
- Partials      113      131      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@breedx-splk
breedx-splk merged commit b9967af into open-telemetry:main Jul 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants